package com.ruihu.admin.module.system.org.domain.entity;

import com.baomidou.mybatisplus.annotation.TableName;
import com.meritit.ws.intfsservicews.MDMOrganization;
import com.ruihu.admin.common.domain.BaseEntity;
import com.ruihu.admin.module.system.org.domain.vo.OrgVO;
import lombok.Data;

import java.util.Date;

/**
 * [  ]
 *
 * @author Tony
 * @version 1.0
 * @company 瑞虎（南京）信息技术有限公司
 * @copyright (c)  瑞虎（南京）信息技术有限公司Inc. All rights reserved.
 * @date 2022-08-30 23:50:33
 * @since JDK1.8
 */
@Data
@TableName("t_org")
public class OrgEntity extends BaseEntity{


    /**
     * 组织机构代码
     */
    private String orgCode;

    /**
     * 组织机构名称
     */
    private String orgName;

    /**
     * 父节点id
     */
    private Long parentId;

    /**
     * 机构排序
     */
    private Integer sort;


    /**
     * 是否删除
     */
    private Integer isDelete;

    public static OrgEntity from(MDMOrganization organization) {
        OrgEntity orgEntity = new OrgEntity();
        orgEntity.setOrgCode(organization.getOrganizationCode());
        orgEntity.setOrgName(organization.getOrganizationName());
        orgEntity.setParentId(0L);
        orgEntity.setIsDelete(0);
        orgEntity.setCreateTime(new Date());
        return orgEntity;
    }

    public static OrgEntity from(OrgVO orgVo) {
        OrgEntity orgEntity = new OrgEntity();
        orgEntity.setOrgCode(orgVo.getOrgCode());
        orgEntity.setOrgName(orgVo.getOrgName());
        orgEntity.setParentId(orgVo.getParentId());
        orgEntity.setIsDelete(0);
        orgEntity.setCreateTime(orgVo.getCreateTime());
        return orgEntity;
    }
}
